import { maintenanceHttp } from '/@/utils/http/axios';
import {
  DeploymentParams,
  ListParam,
  MetricItem,
  MetricParams,
  MonitorItem,
  MonitorParams,
  NodeParams,
  result,
  SummeryItem,
} from '/@/api/maintenance-center/resource-monitor/for-platform/model/monitorModel';

enum Api {
  GET_CCE_LIST = '/v1/maintenance/cloudresource/cceClusterList',
  GET_CSE_LIST = '/v1/maintenance/cloudresource/cseEngineList',
  GET_DCS_LIST = '/v1/maintenance/cloudresource/dcsInstanceList',
  GET_RDS_LIST = '/v1/maintenance/cloudresource/rdsInstanceList',
  GET_METRIC_LIST = '/v1/maintenance/cloudresource/otherMetricName',
  GET_CCE_METRIC_LIST = '/v1/maintenance/cloudresource/cceMetricName',
  GET_MONITOR_LIST = '/v1/maintenance/cloudresource/cceMonitorData',
  GET_OTHER_MONITOR_LIST = '/v1/maintenance/cloudresource/otherMonitorData',
  GET_SUMMERY_RESOURCE = '/v1/maintenance/resourceStatistics/tenant/queryTenantSummaryResource',
  GET_CCE_NODE_LIST = '/v1/maintenance/cloudresource/cceNodes',
  GET_CCE_NAMESPACE_LIST = '/v1/maintenance/cloudresource/cceNameSpace',
  GET_CCE_DEPLOYMENT_LIST = '/v1/maintenance/cloudresource/cceDeployment',
}

export const getTableList = async (params: ListParam) => {
  let url: string;
  switch (params.nameSpace) {
    case 'PAAS.AGGR':
      url = Api.GET_CCE_LIST;
      break;
    case 'SYS.RDS':
      url = Api.GET_RDS_LIST;
      break;
    case 'SYS.DCS':
      url = Api.GET_DCS_LIST;
      break;
    default:
      url = Api.GET_CSE_LIST;
      break;
  }
  //
  // 获取列表
  return await maintenanceHttp.get<result>({ url: url });
};

export const getCceMetricList = async (params: MetricParams) => {
  // 获取下拉列表，请求参数'
  const result = await maintenanceHttp.post<MetricItem[]>({
    url: Api.GET_CCE_METRIC_LIST,
    params,
  });
  return result;
};

export const getMetricList = async (params: MetricParams) => {
  // 获取下拉列表，请求参数
  const result = await maintenanceHttp.get<MetricItem[]>({
    url: Api.GET_METRIC_LIST,
    params,
  });
  return result;
};

export const getMonitor = async (params: MonitorParams) => {
  //获取图表数据
  return await maintenanceHttp.post<MonitorItem[]>({
    url: Api.GET_MONITOR_LIST,
    params,
  });
};

export const getOtherMonitor = async (params: MonitorParams) => {
  //获取图表数据
  return await maintenanceHttp.post<MonitorItem[]>({
    url: Api.GET_OTHER_MONITOR_LIST,
    params,
  });
};

/* eslint-disable */
export const getTenantSummery = async () => {
  // 获取租户资源数据
  const result = maintenanceHttp.get<SummeryItem>({
    url: Api.GET_SUMMERY_RESOURCE,
  });
  return result;
};

export const getNodeIPList = async (params: NodeParams) => {
  return maintenanceHttp.get<string[]>({
    url: Api.GET_CCE_NODE_LIST,
    params,
  });
};

export const getNamespaceList = async () => {
  return maintenanceHttp.get<string[]>({
    url: Api.GET_CCE_NAMESPACE_LIST,
  });
};

export const getDeploymentList = async (params: DeploymentParams) => {
  return maintenanceHttp.get<string[]>({
    url: Api.GET_CCE_DEPLOYMENT_LIST,
    params,
  });
};
/* eslint-disable */
